﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
    public partial class FrmEventSelector : Form
    {
        public FrmEventSelector(Lofas.OlaParser.Event[] events)
        {
            InitializeComponent();
            cmbEvent.DataSource = events;
            cmbEvent.DisplayMember = "Name";
            cmbRace.DisplayMember = "Name";
        }

        private void cmbEvent_SelectedIndexChanged(object sender, EventArgs e)
        {
            cmbRace.DataSource = (cmbEvent.SelectedItem as Lofas.OlaParser.Event).Races;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
        }

        public int EventID
        {
            get
            {
                return (cmbEvent.SelectedItem as Lofas.OlaParser.Event).ID;
            }
        }

        public int RaceID
        {
            get
            {
                return (cmbRace.SelectedItem as Lofas.OlaParser.Race).ID;
            }
        }
        
    }
}
